<?php
namespace app\model;

use support\Model;

class OrderItem extends Model
{
    protected $table = 'ky_order_item';
    protected $primaryKey = 'item_id';
    protected $fillable = [
        'order_id',
        'product_id',
        'product_name',
        'product_type',
        'quantity',
        'price',
        'total_amount',
        'service_date',
        'service_time'
    ];

    protected $casts = [
        'price' => 'float',
        'total_amount' => 'float',
        'service_date' => 'date'
    ];

    /**
     * 获取订单
     */
    public function order()
    {
        return $this->belongsTo(Order::class, 'order_id', 'order_id');
    }

    /**
     * 获取产品
     */
    public function product()
    {
        return $this->belongsTo(ScenicProduct::class, 'product_id', 'product_id');
    }
} 